package com.interview03;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Copyright (C), 2018-2020
 * FileName: Demo2
 * Author:   kongfanyu
 * Date:     2020/12/19 21:09
 */
public class Demo2 {

    public static void main(String[] args) throws InterruptedException {

            List<Integer> list = new CopyOnWriteArrayList<>();
            Thread t1 = new Thread(() -> {
                list.add(100);
            });
            t1.start();

            Thread t2 = new Thread(() -> {
                list.add(200);
            });
            t2.start();

            Thread t3 = new Thread(() -> {
                list.add(300);
            });
            t3.start();

            //t1.join();
            //t2.join();
            //t3.join();
            //Thread.sleep(10000);
        /*while (Thread.activeCount()>2){
            System.out.println("进入activeCount方法");
        }*/
            for (Integer o : list) {
                System.out.println(o);
            }


    }
}
